﻿
namespace GSOrganization.Application;

/// <summary>
/// 系统公共使用部分,生成主键
/// </summary>
public static class Result
    {    
        /// <summary>
         /// 将String转换为Dictionary类型，过滤掉为空的值，首先 6 分割，再 7 分割
         /// </summary>
         /// <param name="value"></param>
         /// <returns></returns>
        public static Dictionary<string, string> StringToDictionary(string value)
        {
           
            Dictionary<string, string> queryDictionary = new Dictionary<string, string>();
            if (!string.IsNullOrWhiteSpace(value))
            {
                string[] s = value.Split('^');
                for (int i = 0; i < s.Length; i++)
                {
                    if (!string.IsNullOrWhiteSpace(s[i]) && !s[i].Contains("undefined") && !s[i].Contains("请选择"))
                    {
                        var ss = s[i].Split('&');
                        if ((!string.IsNullOrEmpty(ss[0])) && (!string.IsNullOrEmpty(ss[1])))
                        {
                            queryDictionary.Add(ss[0], ss[1]);
                        }
                    }

                }
            }
            return queryDictionary;
        }
        /// <summary>
        /// 获取字符串类型的主键
        /// </summary>      
        /// <returns>唯一标识</returns>
        /// <example>(使用示例)</example>     
        public static string GetNewId()
        {

            string id = DateTime.Now.ToString("yyMMddHHmmssfffffff");
            string guid = Guid.NewGuid().ToString().Replace("-", "");

            id += guid.Substring(0, 2);//大并发，可适当调高随机位数
            return id;
        }
    }
 
